package com.taotao.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.taotao.pojo.ItemDesc;
import com.taotao.service.ItemDescService;
@RequestMapping("item/desc")
@Controller
public class ItemDescController {
	
	@Autowired
	private ItemDescService itemDescService;
	
	/**
	 * 根据商品id查询商品描述
	 * @param itemID
	 * @return
	 */
	@RequestMapping(value="{itemId}",method=RequestMethod.GET)
	public ResponseEntity<ItemDesc> getDescByItemID(@PathVariable("itemId")Long itemID){
		
		try {
			ItemDesc itemDesc = itemDescService.queryById(itemID);
			
			if(itemDesc == null) {
				return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
			}
			return ResponseEntity.ok(itemDesc);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
		
	}
}
